package com.crm.cc;

import android.text.TextUtils;

import com.google.gson.Gson;
import com.luck.picture.lib.config.PictureConfig;
import com.luck.picture.lib.config.PictureMimeType;
import com.luck.picture.lib.entity.LocalMedia;

import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

public class PicOption {
    int mimeType= PictureMimeType.ofImage();
    int maxCount=8;
    int minCount=0;
    int multiple=PictureConfig.MULTIPLE;
    boolean preview=true;
    boolean camera=true;
    boolean crop=false;
    boolean compress=true;
    boolean gif=true;
    List<LocalMedia> selected=new ArrayList<LocalMedia>();
    int cropCompressQuality=90;
    int[] cropWH=new int[]{400,800};
    public PicOption() {
    }
    public PicOption(int multiple) {
        this.multiple = multiple;
    }

    public PicOption(int mimeType, int maxCount, int minCount, int multiple, boolean preview, boolean camera, boolean crop, boolean compress, boolean gif, List<LocalMedia> selected, int cropCompressQuality, int[] cropWH) {
        this.mimeType = mimeType;
        this.maxCount = maxCount;
        this.minCount = minCount;
        this.multiple = multiple;
        this.preview = preview;
        this.camera = camera;
        this.crop = crop;
        this.compress = compress;
        this.gif = gif;
        this.selected = selected;
        this.cropCompressQuality = cropCompressQuality;
        this.cropWH = cropWH;
    }

    public int getMimeType() {
        return mimeType;
    }

    public void setMimeType(int mimeType) {
        this.mimeType = mimeType;
    }

    public int getMaxCount() {
        return maxCount;
    }

    public void setMaxCount(int maxCount) {
        this.maxCount = maxCount;
    }

    public int getMinCount() {
        return minCount;
    }

    public void setMinCount(int minCount) {
        this.minCount = minCount;
    }

    public int getMultiple() {
        return multiple;
    }

    public void setMultiple(int multiple) {
        this.multiple = multiple;
    }

    public boolean isPreview() {
        return preview;
    }

    public void setPreview(boolean preview) {
        this.preview = preview;
    }

    public boolean isCamera() {
        return camera;
    }

    public void setCamera(boolean camera) {
        this.camera = camera;
    }

    public boolean isCrop() {
        return crop;
    }

    public void setCrop(boolean crop) {
        this.crop = crop;
    }

    public boolean isCompress() {
        return compress;
    }

    public void setCompress(boolean compress) {
        this.compress = compress;
    }

    public boolean isGif() {
        return gif;
    }

    public void setGif(boolean gif) {
        this.gif = gif;
    }

    public List<LocalMedia> getSelected() {
        return selected;
    }

    public void setSelected(List<LocalMedia> selected) {
        this.selected = selected;
    }

    public int getCropCompressQuality() {
        return cropCompressQuality;
    }

    public void setCropCompressQuality(int cropCompressQuality) {
        this.cropCompressQuality = cropCompressQuality;
    }

    public int[] getCropWH() {
        return cropWH;
    }

    public void setCropWH(int[] cropWH) {
        this.cropWH = cropWH;
    }
    public static PicOption pareOption(Object opt){

        if (opt==null){
            return new PicOption();
        }else {
            if (opt instanceof String||opt instanceof JSONObject){
                Gson gson=new Gson();
                PicOption picOption=gson.fromJson(opt.toString(),PicOption.class);
                return picOption;
            }else {
                return new PicOption();
            }
        }

    }
    public static PicOption pareOption(String opt){
        if (TextUtils.isEmpty(opt)||opt.equals("null")){
            return new PicOption();
        }else {
            Gson gson=new Gson();
            PicOption picOption=gson.fromJson(opt,PicOption.class);
            return picOption;
        }

    }

    @Override
    public String toString() {
       return new Gson().toJson(this);
    }
}
